package threading;
class MyThread extends Thread {
    @Override
    public void run() {
        while (true) {
            System.out.println("hello t ");
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {  //打断异常
                e.printStackTrace();
            }
        }
        //run1();
    }
    public void run1() {
        //while (true) {
            System.out.println("hello t1 ");
        //}
    }
}
public class ThreadDemo {
    public static void main(String[] args) {
        Thread t = new MyThread();
        t.start();  //这是创建新线程的入口
        //t.run();   //run是子类重写了父类的方法，可以直接调用
        //((MyThread)t).run1();  // run1 是子类独有的方法，需要进行向下转型才可以调用的
        while (true) {
            System.out.println("hello main");
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
